
package Econbuddy;

/* Team Directories
 *
 * You are free to do whatever you want with this code. Frankly we don't give a damn.
 * 
 *  
 * Copyright GNU General Public License v3
 */

/**
 *
 * 
 */
import BuddyTemplate.*;
import javax.swing.*;
import java.io.*;
import java.util.*;
        
public class Main implements StudyBuddy.RunnableBuddy{

    /**
     * @param args the command line arguments
     */
    
    String username;
    Integer thescore = new Integer(0);
    QuestionLayerCollection questions = new QuestionLayerCollection();
    
    public static void main(String[] args) {
        
        Main x = new Main();
        x.run();
        
    }
    
    public void run(){
        
        /* We Populate the QuestionCollection with questions*/
        
        Question<String, String> testquestion = new Question<String, String>();
        testquestion.setQuestion("The oil crisis caused U.S. oil companies' overseas profits to shoot up, producing a jump in ______ that could mislead policy-makers.' The blank should be");
        testquestion.setDifficulty(0);
        testquestion.setChoice("GDP", false);
        testquestion.setChoice("GNP", true);
        testquestion.setChoice("investment", false);
        testquestion.setChoice("interest rates", false);
        
        questions.addQuestion(testquestion);
        
        Question<String, String> testquestion2 = new Question<String, String>();
        testquestion2.setQuestion("\"Homemakers often feel their work is taken for granted, and advocates in the women's movement argue that the statistical invisibility of homemakers' work has substantive policy implications.\" What is meant by \"statistical invisibility\" here?");
        testquestion2.setDifficulty(0);
	testquestion2.setChoice("homemakers' output is not counted in GDP", true);
        testquestion2.setChoice("homemakers' output is double-counted in GDP", false);
        testquestion2.setChoice("homemakers' output is added into GDP at an artificially-low price", false);
        testquestion2.setChoice("homemakers' output is only counted into GDP if there exists a market counterpart", false);
        
        questions.addQuestion(testquestion2);
        
        
        Question<String, String> testquestion3 = new Question<String, String>();
        testquestion3.setQuestion("Suppose that inventories fall by $2b, consumption increases by $8b, unemploymentinsurance payments decline by $4b and imports rise by $1b. Then measured GDP should rise by");
        testquestion3.setDifficulty(0);
        testquestion3.setChoice("5b", true);
        testquestion3.setChoice("7b", false);
        testquestion3.setChoice("9b", false);
        testquestion3.setChoice("11b", false);
        
        questions.addQuestion(testquestion3);
        
        Question<String, String> testquestion4 = new Question<String, String>();
        testquestion4.setQuestion("If the price index is 120 in 1989 and 150 in 1990, what is the rate of inflation?");
        testquestion4.setDifficulty(0);
        testquestion4.setChoice("20%", false);
        testquestion4.setChoice("25%", true);
        testquestion4.setChoice("30%", false);
        testquestion4.setChoice("more than 30%", false);
        
        questions.addQuestion(testquestion4);
        
        Question<String, String> testquestion5 = new Question<String, String>();
        testquestion5.setQuestion("Because pollution is a byproduct of many production processes, GDP accountants should adjust GDP _______ but do not, causing GDP to ________ economic welfare. The blanks are best filled with");
        testquestion5.setDifficulty(0);
	testquestion5.setChoice("automobile",false);
        testquestion5.setChoice("housing", true);
        testquestion5.setChoice("clothing", false);
        testquestion5.setChoice("government bond",false);
       
        
        questions.addQuestion(testquestion5);
        
        
	Question<String, String> testquestion6 = new Question<String, String>();
	testquestion6.setQuestion("If \"the\" multiplier is 4 and the government wants to increase the level of income by $30 billion, it should increase government spending by");
        testquestion6.setDifficulty(1);
	testquestion6.setChoice("$4b", true);
        testquestion6.setChoice("$2b", false);
        testquestion6.setChoice("$7b", false);
        testquestion6.setChoice("$9b", false);   

        questions.addQuestion(testquestion6);
        
	
	Question<String, String> testquestion7 = new Question<String, String>();
	testquestion7.setQuestion("Suppose that the income multiplier with respect to government spending is 2.5 and the marginal tax rate is 25 percent. If the government increases spending by 8 billion dollars, the budget deficit will");
        testquestion7.setDifficulty(1);
	testquestion7.setChoice("decrease or be unaffected", false);
        testquestion7.setChoice("increase by $3b or less", true);
        testquestion7.setChoice("increase by more than $3b but less than $8b", false);
        testquestion7.setChoice("increase by $8b or more", false);   

        questions.addQuestion(testquestion7);
        
	
	Question<String, String> testquestion8 = new Question<String, String>();
	testquestion8.setQuestion("If everyone is forced to pay an extra $100 in taxes each year, \"the\" multiplier");
        testquestion8.setDifficulty(1);
	testquestion8.setChoice("is unchanged", true);
        testquestion8.setChoice("becomes larger", false);
        testquestion8.setChoice("becomes smaller", false);
        testquestion8.setChoice("not enough information to tell", false);   

        
	questions.addQuestion(testquestion8);
        
	Question<String, String> testquestion9 = new Question<String, String>();
	testquestion9.setQuestion("The reaction of nitrogen dixoide with water yields:");
        testquestion9.setDifficulty(1);
	testquestion9.setChoice("HNO3", false);
        testquestion9.setChoice("NH3 and O2", false);
        testquestion9.setChoice("NO and 2OH", true);
        testquestion9.setChoice("NO and OH", false);   

        questions.addQuestion(testquestion9);
        
	Question<String, String> testquestion10 = new Question<String, String>();
	testquestion10.setQuestion("A conservative who was concerned with the growth in government but who believed in the Keynesian concept of demand management would most likely support which of the following expansionary policies");
        testquestion10.setDifficulty(1);
	testquestion10.setChoice("a decrease in taxes", false);
        testquestion10.setChoice("an increase in taxes", true);
        testquestion10.setChoice("a decrease in government spending", false);
        testquestion10.setChoice("an increase in government spending", false);
	
	questions.addQuestion(testquestion10);

	Question<String, String> testquestion11 = new Question<String, String>();
	testquestion11.setQuestion("Which have the longer wavelength given the same kinetic energy, an electron or a proton?");
        testquestion11.setDifficulty(2);
	testquestion11.setChoice("The electon, due to a smaller mass", true);
        testquestion11.setChoice("The electon, due to a bigger mass", false);
        testquestion11.setChoice("The proton, due to a bigger mass", false);
        testquestion11.setChoice("The proton, due to a small mass", false);
	
	questions.addQuestion(testquestion11);

	Question<String, String> testquestion12 = new Question<String, String>();
	testquestion12.setQuestion("A stimulating dose of fiscal policy can be applied either by increasing government spending or by decreasing taxes. For most people the main reason for preferring one to the other is");
        testquestion12.setDifficulty(2);
	testquestion12.setChoice("a belief that one is easier to do than the other", false);
        testquestion12.setChoice("a belief that one is faster to enact than the other", false);
        testquestion12.setChoice("a belief that one has a larger multiplier effect than the other", false);
        testquestion12.setChoice("a subjective preference for larger or smaller government activity", true);
	
	questions.addQuestion(testquestion12);

	Question<String, String> testquestion13 = new Question<String, String>();
	testquestion13.setQuestion("Calculate the change in energy in kJ per mole for atoms that emit light at a wavelength of 486nm");
        testquestion13.setDifficulty(2);
	testquestion13.setChoice("2.46*10^2 kJ", false);
        testquestion13.setChoice("1.57*10^2 kJ", false);
        testquestion13.setChoice("-2.46*10^2 kJ", true);
        testquestion13.setChoice("-1.57*10^2 kJ", false);
	
	questions.addQuestion(testquestion13);

	Question<String, String> testquestion14 = new Question<String, String>();
	testquestion14.setQuestion("\"When the yen went through the roof early in the year we all expected it to produce bad news later on. Well, surprise surprise, here it is.\" This produces bad news later for Japan because the higher yen");
        testquestion14.setDifficulty(2);
	testquestion14.setChoice("increases inflation", false);
        testquestion14.setChoice("prompts the central bank to increase interest rates", false);
        testquestion14.setChoice("increases the Japanese natural rate of unemployment", false);
        testquestion14.setChoice("reduces exports which through a multiplier effect decreases income", true);
	
	questions.addQuestion(testquestion14);

       
        
        // This is the rather inelegant pieces of code which get the Ball Rolling
   
        // First we increase the state of the question - we request the nextquestion 
       
        Question thenextquestion = questions.nextQuestion();
        
        // Now depending on what question the first question is, we launch the appopriate window
        // Note that this same bit of code is also used in PictureFrame, PictureChoiceFrame, etc
        
        // We get the instance of the choice of the first method
        if(thenextquestion.choices.get(0) instanceof String && thenextquestion.getQuestion() instanceof String){
            QuestionFrame nextQuestion = new QuestionFrame(thescore, questions, thenextquestion);
            nextQuestion.setVisible(true);
        }
                
        else if(thenextquestion.choices.get(0) instanceof ImageIcon && thenextquestion.getQuestion() instanceof String){
            PictureFrame nextQuestion = new PictureFrame(thescore, questions, thenextquestion);
            nextQuestion.setVisible(true);
        }
                
        else if(thenextquestion.choices.get(0) instanceof String && thenextquestion.getQuestion() instanceof ImageIcon){
            PictureChoiceFrame nextQuestion = new PictureChoiceFrame(thescore, questions, thenextquestion);
            nextQuestion.setVisible(true);
        }
        
    }
    
    public String getName(){
        
        return "ECON Buddy";
        
    }
    
    public int getScore(){
       
        return SaveGame.score;
        
    }
    
    public void setLoginInfo(String theusername){
        
        username = theusername;
        
    }
    
    
    public Serializable getSavedGame(){
        
        return new SaveGame();
        
    }
    
    public void loadSavedGame(Serializable savegame){
        
        thescore = ((SaveGame)savegame).score;
        
    }
    
    

    

}
